<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>练习</title>
</head>
<body>
    <form>
        <input type="text" id="username" />
        <input type="password" id="pwd" />
        <input type="submit" id="sub" value="登录" />
    </form>


</body>
<script>
    var f1=document.getElementById("f1");
    var username=document.getElementById("username");
    var pwd=document.getElementById("pwd");
    var sub=document.getElementById("sub");
    username.onblur=function(){
        var val=username.value;
        if(val.length<3){
            alert("用户名过短");
        }
    }
    pwd.onfocus=function(){
        var vl=pwd.value;
        if(vl.length>3){
            alert("用户名过长");
        }
    }
    sub.onsubmit=function(){
        alert("表单提交");
    }
    (function(username1){
        console.log(username1);
    })("张三");
    var add=function(x,y){
     return x+y;
    }
     add (1,2);
   /* f1.onclick=function(){
        alert("div被点击了");

    }*/
   /*window.onload=function(){
       console.log("页面加载完成!");
   }
   window.onunload=function(){
       alert("页面关闭");

   }*/

</script>
</html>